#!/usr/bin/env node

const fs = require('fs'),
      fileName = process.argv[2],
      log = console.log;

//实现打印带有行号的文件内容，使用字符串分割
try{
  let data = fs.readFileSync(fileName).toString('utf8').split('\n');
  for(let i=0;i<data.length;i++){
    log(`${i+1} ${data[i]}`); 
  }

}catch(e){
  log(e.message);
}


//let num = 1;
//fs.readFileSync(fileName)
//  .toString('utf8')
//  .split('\n')
//  .forEach((line)=> log(`${num++}\t${line}`));

